package great.project.param.config.convert;

import great.project.param.domain.RequestParams;
import org.springframework.core.convert.converter.Converter;
import org.springframework.lang.NonNull;

/**
 *  <div  style="border:2px solid none;margin:20px;padding:15px;font-size:24px;text-align:center;color:aqua;">
 *
 *
 *
 *  </div>
 * @author v_zhangshun01
 * @date 2021/11/26 4:07 下午
 */
public class RequestParamsConvert implements Converter<String, RequestParams> {


    @Override
    public RequestParams convert(@NonNull String source) {

        if (source.contains("$")) {
            final String[] split = source.split("\\$");
            return RequestParams.builder()
                    .name(split[0])
                    .age(Integer.parseInt(split[1]))
                    .build();
        }

        return null;
    }
}
